from selenium.webdriver.common.by import By
from pom.base_page import BasePage
import time


class SysToolPage(BasePage):
    def form_construction(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[4]/li/ul/div[1]/a/li').click()

        time.sleep(2)

    def code_generation(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[4]/li/ul/div[2]/a/li').click()

        time.sleep(2)
        table_name = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        table_describe = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        entity = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[5]/div').text
        print(table_name, table_describe, entity, "***************************")

        assert table_name == "application"
        assert table_describe == "应用信息表"
        assert entity == "Application"

        # search
        time.sleep(1)
        self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/form/div[1]/div/div/input').send_keys("audit")
        self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/form/div[2]/div/div/input').send_keys("审核记录")
        self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/form/div[4]/div/button[1]').click()

        time.sleep(2)
        s_table_name = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        s_table_describe = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        s_entity = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[5]/div').text
        print(s_table_name, s_table_describe, s_entity, "***************************")

        assert s_table_name == "audit_log"
        assert s_table_describe == "审核记录表"
        assert s_entity == "AuditLog"

    def os_api(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[4]/li/ul/div[3]/a/li').click()

        time.sleep(2)

